Skip to content

feat(mesh-store): converge room membership as a per-agent element set - #34

Merged
Mearman merged 2 commits into
mainfrom
feat/element-set-membership
Sep 9, 2026
Merged

feat(mesh-store): converge room membership as a per-agent element set#34
Mearman merged 2 commits into
mainfrom
feat/element-set-membership

Conversation

@Mearman

@Mearman Mearman commented Sep 9, 2026

Copy link
Copy Markdown
Member

Follow-up to #29, resolving the equal-version join/leave boundary documented on #27 properly instead of accepting it.

Membership was merged by version-gated replacement with a union on equal revisions — which protected concurrent joins of different agents but made a kick racing a concurrent join converge with the joiner retained until some later mutation resolved the tie. Membership is now a last-write-wins element set: each room carries the revision of every agent's latest join to and leave from the member and invited lists; an agent is in a list exactly when their join strictly outranks their leave; merges take the highest revision per agent per list.

Consequences:

  • joins of different agents are independent keys — they never interact, preserving what the union existed to protect;
  • an exact join/leave tie resolves to out, so a concurrent kick and join of the same agent converges deterministically with the kick honoured, on every peer;
  • the members and invited arrays become derived views, refreshed after every mutation and merge — the hand-maintained pushes and filters at each mutation site are gone, along with the tie-union special case in both merge paths.

Scalar room fields keep the version gate from #29 (renames and edits still heal through wholesale replace); only membership switched to element merge. The FileStore maintains the same maps so its records stay shape-compatible.

Tests pin both concurrency outcomes — kick-beats-racing-join in both sync directions, and both-of-two-concurrent-joins surviving with identical member lists — alongside the existing convergence suite. 23 tests, three clean rounds, lint/typecheck/build green.

Wire-format groundwork for convergent membership merges: four records
holding the room revision of each agent's latest join to and leave from
the member and invited lists, with members and invited as derived
views.
Room membership was merged by version-gated record replacement with a
union on equal revisions, which protected concurrent joins of different
agents but made a leave or kick racing a concurrent join converge with
the joiner retained — a kicked agent stayed a member until the next
room mutation resolved the tie.

Membership is now a last-write-wins element set: each room carries the
revision of every agent's latest join to and leave from the member and
invited lists, an agent is in a list when their join strictly outranks
their leave, and merges take the highest revision per agent per list.
Joins of different agents are independent keys and never interact, and
an exact join/leave tie resolves to out, so a kick racing a join
converges with the kick honoured. The members and invited arrays become
derived views refreshed after every mutation and merge, replacing the
hand-maintained pushes and filters at each site.

Scalar room fields keep the version gate; only membership switched to
element merge, so renames and edits still heal through the higher
version replacing the record. The FileStore maintains the same
operation maps so its records stay shape-compatible.
@Mearman
Mearman marked this pull request as ready for review September 9, 2026 11:00
@Mearman
Mearman merged commit 0dae92e into main Sep 9, 2026
5 checks passed
@Mearman
Mearman deleted the feat/element-set-membership branch September 9, 2026 11:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-09T11:11:37.505625Z af16472 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.26.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant